package com.apes.scm.masterdata.product.service;

import com.apes.scm.masterdata.product.model.FaDepreciationMethod;
import com.apes.scm.masterdata.product.repository.FaDepreciationMethodRepository;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @BelongsProject: apes-server
 * @BelongsPackage: com.apes.fa.service
 * @ClassName: DepreciationMethodService
 * @Author: PengZiFeng
 * @Description: 折旧方法服务
 * @CreateTime: 2021-08-13 11:48
 * @Version: 1.0
 */
@Service("faDepreciationMethodService")
public class FaDepreciationMethodService extends DomainService {

    @Autowired
    private FaDepreciationMethodRepository depreciationMethodRepository;

    /**
     * 保存
     * @param request
     * @return
     */
    public FaDepreciationMethod save(SimpleRequest request) {
        FaDepreciationMethod depreciationMethod = request.getO(FaDepreciationMethod.class);
        return depreciationMethodRepository.saveAndFlush(depreciationMethod);
    }

    /**
     * 删除
     * @param request
     * @return
     */
    public String delete(SimpleRequest request) {
        FaDepreciationMethod depreciationMethod = request.getO(FaDepreciationMethod.class);
        depreciationMethodRepository.delete(depreciationMethod.getId());
        return "删除成功";
    }

}
